package com.crm.common.utils;

public class DesensitizedUtils {

    public static  String mobilePhone(String num){
        String phone = num.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
        return phone;
    }

    public static String mobileWechat(String num){
        if(num.length() == 0){
            return "";
        }else if(num.length() == 1){
            return "*";
        }else if(num.length() == 2){
            return num.replaceAll("(\\d{1})\\d{1}", "$1*");
        }else{
            int len = num.length() - 2;
            String str = "";
            for(int i = 0;i<len;i++){
                str = str + "*";
            }
            String replace = num.replaceAll(num.substring(1, num.length() - 1), str);
            return replace;
        }
    }

}
